#ifndef COMMWITH_BOARD_H
#define COMMWITH_BOARD_H

#include <QObject>
#include <QThread>
#include <mqueue.h>
#include "commSignal.h"

#define QUEUE_IO_QT "/io_qt_comm"
#define MAX_MSG_SIZE    256

// 后台线程：监听消息队列
class BoardRecvThread : public QThread {
    Q_OBJECT
public:
    explicit BoardRecvThread(QObject *parent = nullptr);
    ~BoardRecvThread();

signals:
    void messageReceived(const QString &msg);

protected:
    void run() override;

private:
    mqd_t mq_;
    bool running_ = true;
};

// 主类：连接信号发出到桥接层
class commWithBoard : public QObject
{
    Q_OBJECT
public:
    explicit commWithBoard(QObject * parent = nullptr);
    ~commWithBoard();
    CommSignal * boardSigToBridge;

private slots:
    void onMessageReceived(const QString &msg);

private:
    BoardRecvThread *recvThread_;
};


#endif // COMMWITH_BOARD_H